import java.util.Scanner;

public class Main {
    //递归求解汉诺塔问题
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        System.out.println("请输入盘子的个数：");
        int num=in.nextInt();
        hanota('A','B','C',num);

        in.close();
    }
    public static void hanota(char ch1,char ch2,char ch3,int num){
        if(num==1){
            move(ch1,ch3);
        }else{
            hanota(ch1,ch3,ch2,num-1);
            move(ch1,ch3);
            hanota(ch2,ch1,ch3,num-1);
        }
    }
    public static void move(char ch1,char ch2){
        System.out.print(ch1+"——>"+ch2+"  ");
    }












    //迭代求 N 的阶乘
    public static void main7(String[] args) {
        Scanner in=new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int num= in.nextInt();
        int sum=1;
        for (int i = 1; i <= num; i++) {
            sum*=i;
        }
        System.out.println(num+"的阶乘为"+sum);

        in.close();
    }












    //在同一个类中定义多个方法：要求不仅可以求2个整数的最大值，还可以求3个小数的最大值
    public static void main6(String[] args) {
        int a1=7,a2=8;
        double b1=3.3,b2=4.4,b3=5.5;
        System.out.println(max(a1, a2));
        System.out.println(max(b1, b2, b3));

    }
    public static int max(int n1,int n2) {
        if (n1 < n2)
            return n2;
        return n1;
    }
    public static double max(double b1,double b2,double b3){
        double max=Math.max(b1,b2);
        max=Math.max(max,b3);
        return max;
    }











    //在同一个类中,分别定义求两个整数的方法 和 三个小数之和的方法。 并执行代码，求出结果
    public static void main5(String[] args) {
        int a1=7,a2=8;
        double b1=3.3,b2=4.4,b3=5.5;
        System.out.println(add(a1, a2));
        System.out.println(add(b1, b2, b3));

    }
    public static int add(int n1,int n2){
        return n1+n2;
    }
    public static double add(double b1,double b2,double b3){
        return b1+b2+b3;
    }









    //求斐波那契数列的第n项。(迭代实现)
    public static void main4(String[] args) {
        Scanner in=new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int num= in.nextInt();
        int s=0;
        if(num==1||num==2)
            s=num-1;
        else{
            int n1=0;
            int n2=1;
            for (int i = 3; i <= num; i++) {
                s=n1+n2;
                n1=n2;
                n2=s;
            }
        }
        System.out.println("斐波那契数列的第"+num+"项为："+s);

        in.close();
    }








    //求阶乘和
    public static void main3(String[] args) {
        Scanner in=new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int num=in.nextInt();
        int sum=0;
        for (int i = 1; i <= num; i++) {
            sum+=fac(i);
        }
        System.out.println("这个数的阶乘和是："+sum);

        in.close();
    }












    //求 N 的阶乘
    public static void main2(String[] args) {
        Scanner in=new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int num=in.nextInt();
        System.out.println(fac(num));

        in.close();
    }

    public static int fac(int num){
        if(num==1||num==0)
            return 1;
        return num*fac(num-1);
    }










    //在max3这个函数中，调用max2函数，来实现3个数的最大值计算
    public static void main1(String[] args) {
        Scanner in=new Scanner(System.in);
        System.out.println("请输入两个数：");
        double n1= in.nextDouble();
        double n2=in.nextDouble();
        double m2=max2(n1,n2);
        System.out.println(m2+"最大");
        System.out.println("请输入三个数：");
        n1=in.nextDouble();
        n2=in.nextDouble();
        double n3=in.nextDouble();
        m2=max3(n1,n2,n3);
        System.out.println(m2+"最大");

        in.close();
    }

    public static double max2(double n1,double n2) {
        if (n1 < n2)
            return n2;
        return n1;
    }

    public static double max3(double n1,double n2,double n3){
        double num=max2(n1,n2);
        return max2(num,n3);
    }

}


